using Headspring.Training.Domain.Services;
using Headspring.Training.WebUI.Views;

namespace Headspring.Training.WebUI.Presenters
{
	public class LayoutPresenter
	{
		private readonly IUserSession _session;

		public LayoutPresenter(IUserSession session)
		{
			_session = session;
		}

		public void Execute(ILayoutView view)
		{
			view.CurrentUser = _session.GetCurrentUser();
			FlashMessage message = _session.PopUserMessage();
			while(message != null)
			{
				view.AddFlashMessage(message);
				message = _session.PopUserMessage();
			}
		}
	}
}